﻿using System.Collections.Generic;
using System.Configuration;
using System.Web.Mvc;
using DevTrends.MvcDonutCaching;
using ECG.Common;
using ECG.DAL;
using ECG.WebUI.Models;

namespace ECG.WebUI.Controllers
{
    public class ProductTagController : Controller
    {
        //
        // GET: /ProductTag/
        [DonutOutputCache(CacheProfile = "OneDay")]
        public ActionResult ProductListByTag(string tag = "", int id = 0, int page = 1)
        {
            var totalPage = 0;
            var totalRecord = 0;
            var itemsPerPage = int.Parse(ConfigurationManager.AppSettings["ItemsPerPageDefault"]);
            var model = ProductTagDb.GetProductListByTag(id, page, itemsPerPage, out totalPage, out totalRecord) ?? new List<ProductRateByCateTopListPagingDto>();

            ViewBag.TotalRecord = totalRecord;
            ViewBag.TagName = ProductTagDb.GetNameByProductTagId(id) ?? "";
            ViewBag.PageInfo = new PageInfo { CurrentPage = page, PageSize = itemsPerPage, TotalPages = totalPage };
            ViewBag.CurrentPage = page;
            return View(model);
        }

    }
}
